/**
 * 
 */
package com.pkdl.forms;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
import java.awt.SystemColor;
import java.util.List;

import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;

import com.pkdl.dao.BenhNhanChoKhamDAO;
import com.pkdl.dto.BenhNhanChoKhamDTO;
import com.pkdl.tables.TableCapNhatBenhNhanHienThoi;

/**
 * @author Administrator
 * 
 */
public class DlgCapNhatBenhNhanHienThoi extends JDialog {

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			DlgBenhNhanHienThoi dialog = new DlgBenhNhanHienThoi(null, true);
			dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private JTable tblData;
	private BenhNhanChoKhamDAO bnckDAO;

	/**
	 * Create the dialog.
	 */
	public DlgCapNhatBenhNhanHienThoi(Frame parent, boolean modal) {
		super(parent, modal);
		this.setTitle("Danh sach benh nhan hien thoi");
		this.setBounds(100, 100, 728, 592);
		this.setLocationRelativeTo(null);

		JPanel panel = new JPanel();
		panel.setPreferredSize(new Dimension(452, 10));
		this.getContentPane().add(panel, BorderLayout.CENTER);
		panel.setLayout(new BorderLayout(0, 0));

		JPanel panel_1 = new JPanel();
		panel_1.setBackground(SystemColor.textHighlight);
		panel.add(panel_1, BorderLayout.CENTER);
		panel_1.setLayout(new BorderLayout(0, 0));

		JLabel lblDanhSchBnh = new JLabel(
				"  Danh s\u00E1ch b\u1EC7nh nh\u00E2n hi\u1EC7n th\u1EDDi");
		lblDanhSchBnh.setPreferredSize(new Dimension(46, 32));
		lblDanhSchBnh.setHorizontalAlignment(SwingConstants.CENTER);
		lblDanhSchBnh.setForeground(Color.WHITE);
		lblDanhSchBnh.setFont(new Font("Tahoma", Font.BOLD, 18));
		panel_1.add(lblDanhSchBnh, BorderLayout.NORTH);

		JScrollPane scrollPane = new JScrollPane();
		panel_1.add(scrollPane, BorderLayout.CENTER);
		{
			this.tblData = new JTable();
			this.tblData.setFillsViewportHeight(true);
			this.tblData.setModel(new DefaultTableModel(new Object[][] {
					{ null, null, null, null, null },
					{ null, null, null, null, null },
					{ null, null, null, null, null }, }, new String[] {
					"New column", "New column", "New column", "New column",
					"New column" }));
			scrollPane.setViewportView(this.tblData);
		}
		this.loadData();
	}

	/**
	 * Load danh sach thuoc
	 */
	private void loadData() {
		this.bnckDAO = new BenhNhanChoKhamDAO();
		List<BenhNhanChoKhamDTO> ds = this.bnckDAO.selectAll();
		TableCapNhatBenhNhanHienThoi table = new TableCapNhatBenhNhanHienThoi(
				ds);
		table.loadDataIntoTable(this.tblData);
	}

}
